function y = gain(x, tr, dt, t0, a, type)
if nargin < 6
    type = 'power';
end
t = (0:size(x, 1)-1)*dt;
switch type
    case 'power'
        w = t-t0;
        w(w<=0)=0;
        w = w.^a;
    case 'exp'
        w = exp((t-t0)*a)-1;
        w(t<t0)=0;
end
y = diag(w)*x;
end